package com.wanxi.map;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class StudentTreeMapTest {
    public static void main(String[] args) {
        Map<Student, String> map = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge() - o2.getAge();
            }
        });
        map.put(new Student("001", "张三", 11), "四川");
        map.put(new Student("001", "李四", 22), "云南");
        map.put(new Student("003", "王五", 14), "贵州");
        System.out.println(map);
    }
}
